<?php
/**
 * Created by PhpStorm.
 * User: admin
 * Date: 2018/12/21
 * Time: 15:07
 */

namespace app\api\model;


use think\Db;

class GameModel
{
    public static $table = 'game';

    /**
     * @param array $where
     * @param int $page
     * @param int $pageSize
     * @return false|\PDOStatement|string|\think\Collection
     * @throws \think\db\exception\DataNotFoundException
     * @throws \think\db\exception\ModelNotFoundException
     * @throws \think\exception\DbException
     */
    public static function lists($where = [], $page = 1, $pageSize = 10)
    {
        $db = Db::name(self::$table);
        if (isset($where['id'])) {
            if (is_array($where['id'])) {
                $db->where('id', 'in', $where['id']);
            } else {
                $db->where('id', $where['id']);
            }
        }
        if (isset($where['major_type'])) {
            $db->where('major_type', $where['major_type']);
        }

        $list = $db->page($page, $pageSize)->select();
        return $list;
    }

    public static function all($where = [])
    {
        $db = Db::name(self::$table);
        if (isset($where['id'])) {
            if (is_array($where['id'])) {
                $db->where('id', 'in', $where['id']);
            } else {
                $db->where('id', $where['id']);
            }
        }
        if (isset($where['major_type'])) {
            $db->where('major_type', $where['major_type']);
        }

        $list = $db->select();
        return $list;
    }
}